home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Guide 18
/
PC Guide CD-ROM (PCCD-18-12-96) (1996).iso
/
cylindrx
/
clock
/
ifingerb.wil
< prev
next >
Wrap
Text File
|
1996-08-29
|
2KB
|
70 lines
;******** Sample Winsock app using blocking socket ********
szTitle = "ClockMan Finger pgm"
;Dial our host...
hConn = SDialUp ("%param1%")
if (!hConn)
nRet = SGetLastErr ()
Message (szTitle, "SDialUp error = %nRet%")
exit
endif
szHost = "x"
szCmd = "x"
while (szHost<>"" && szCmd<>"")
; Get a finger request...
szHost = AskLine (szTitle, "Enter the host to query:", "")
if (szHost=="")
goto HangUp
endif
szCmd = AskLine (szTitle, "Enter the finger request:", "")
if (szCmd=="")
goto HangUp
endif
; Create a socket...
hSock = SOpen (@SBlocking)
if (hSock==@SErrSocket)
Message (szTitle, "Couldn't create socket.")
goto HangUp
endif
; Connect it up...
nRet = SConnect (hSock, szHost, "finger")
if (nRet <> @TRUE)
nErr = SGetLastErr ()
Message (szTitle, "IConnect error: %nErr%")
goto CloseSocket
endif
; Send our Finger request...
nRet = SSendLine (hSock, szCmd)
if (nRet<>@SOK)
Message(szTitle, "Error %nRet% sending command.")
goto CloseSocket
endif
; Get all lines from Finger server till it closes the connection...
szResponse = ""
szLine = SRecvLine (hSock, 32767)
nRet = SGetLastErr()
while (nRet<>@SErrNoConn)
if (nRet == @SOK)
szResponse = StrCat (szResponse, szLine, @CRLF)
endif
Yield ()
szLine = SRecvLine (hSock, 32767)
nRet = SGetLastErr()
endwhile
Message (szTitle, szResponse)
; Close the socket...
:CloseSocket
nRet = SClose (hSock)
endwhile
; Hang up...
:HangUp
nRet = SHangUp (hConn)